package com.carpedil.redis.jedis;

import java.io.*;

/** @author Administrator */
public class SerializeUtil {

  public static byte[] serialize(Object obj) {
    ObjectOutputStream obi = null;
    ByteArrayOutputStream bai = null;
    try {
      bai = new ByteArrayOutputStream();
      obi = new ObjectOutputStream(bai);
      obi.writeObject(obj);
      return bai.toByteArray();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return null;
  }

  public static Object decSerizlize(byte[] byt) {
    ObjectInputStream oii = null;
    ByteArrayInputStream bis = null;
    bis = new ByteArrayInputStream(byt);
    try {
      oii = new ObjectInputStream(bis);
      return oii.readObject();
    } catch (Exception e) {

      e.printStackTrace();
    }

    return null;
  }
}
